﻿using System;
using System.Text;
using System.Data;
using SME.Food.Surperise.BLL;

namespace SME.Food.Tricon.Web.AdminJS.UserManage
{
    public partial class UserList : System.Web.UI.Page
    {
        public  Bas_User_BLL bll = new Bas_User_BLL();
        public string Mempower = "";
        protected void Page_Load(object sender, EventArgs e)
        {
             Mempower = Request.QueryString["mempower"];
            TooBar(Mempower);
            GetSingleSearch();
            BindData();
        }

        public void TooBar(string power)
        {
            if (power == "0")
            {
                string addstr="<li><a class='add' title='员工用户' href='UserManage/UserModify.aspx?type=modify' target='dialog' rel='dialogs' width='416' height='283'><span>添加</span></a></li>";
                TooBars += addstr;
                string delstr ="<li><a title='确实要删除这些记录吗?' target='selectedTodo' rel='ids' posttype='string' href='UserManage/UserH.aspx?type=deleteAll' class='delete'><span>批量删除</span></a></li>";
                TooBars += delstr;
            }
        }

        public void GetSingleSearch()
        {
            SearchUserName = Request.Form["SearchUserName"];
            SearchMemName = Request.Form["SearchMemName"];
        }

        public void BindData()
        {
            StringBuilder sqlWhere = new StringBuilder();
            if (!string.IsNullOrEmpty(SearchUserName))
            {
                sqlWhere.AppendFormat(" and User_Name like '%{0}%'", SearchUserName);
            }
            if (!string.IsNullOrEmpty(SearchMemName))
            {
                sqlWhere.AppendFormat(" and Mem_Name={0}", Int32.Parse(SearchMemName));
            }
            Table = bll.GetList(sqlWhere.ToString()).Tables[0];

        }

        /// <summary>
        /// 用户检索
        /// </summary>
        public string SearchUserName { get; set; }
       
        /// <summary>
        /// 是否到期
        /// </summary>
        public string PageNum { get; set; }
        /// <summary>
        /// 员工姓名检索
        /// </summary>
        public string SearchMemName { get; set; }
        /// <summary>
        /// 企业编号
        /// </summary>
        public string NumPerPage { get; set; }
        /// <summary>
        /// 企业名称
        /// </summary>
        public DataTable Table { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public string TooBars { get; set; }
    }
}